package com.huxin.servelt;

import com.alibaba.fastjson.JSON;
import com.huxin.pojo.BookHisInfo;
import com.huxin.pojo.BooksInfo;
import com.huxin.pojo.ConditionalQueryDTO;
import com.huxin.service.Userservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 查询该用户的借书信息
 */
@WebServlet("/selectAllBooksStatus")
public class SelAllBooksStatusServlet extends HttpServlet {
    private Userservice userservice = new Userservice();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //todo
        Integer userId = (Integer) request.getSession().getAttribute("userId");
        List<BookHisInfo> bookHisInfos = userservice.selectAllById(userId);
        String jsonString = JSON.toJSONString(bookHisInfos);
        response.getWriter().write(jsonString);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
